//
//  HHYTopTitleView.m
//  大股票
//
//  Created by apple on 2019/8/14.
//  Copyright © 2019 apple. All rights reserved.
//

#import "HHYTopTitleView.h"

@interface HHYTopTitleView ()

@property (strong, nonatomic) IBOutletCollection(UILabel) NSArray *topTitleArr;
@property (nonatomic, strong) UIView *contentView;

@end

@implementation HHYTopTitleView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addSubview:self.contentView];
        
        [self updateUI];
    }
    
    return self;
}

- (void)updateUI
{
    
}

#pragma mark - setter
- (void)setTitleArr:(NSArray *)titleArr {
    _titleArr = titleArr;
    
    dispatch_async(dispatch_get_main_queue(), ^{
        //赋值
        if (titleArr.count == self.topTitleArr.count) {
            int i = 0;
            for (NSString *title in titleArr) {
                UILabel *label = self.topTitleArr[i++];
                label.text = title;
            }
        }
    });
    
}


#pragma mark - getter
- (UIView *)contentView {
    if (!_contentView) {
        UINib *nib = [UINib nibWithNibName:@"hhy_TopTitleView" bundle:nil];
        NSArray *objs = [nib instantiateWithOwner:self options:nil];
        _contentView = objs[0];
        _contentView.frame = self.bounds;
    }
    return _contentView;
}

@end
